home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 3.8 KB | 146 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWButton.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWBUTTON_H
- #define FWBUTTON_H
-
- // ----- Foundation Includes -----
-
- #ifndef FWNOTIFN_H
- #include "FWNotifn.h"
- #endif
-
- #ifndef FWNOTIFR_H
- #include "FWNotifr.h"
- #endif
-
- // ----- OS Includes -----
-
- #ifndef FWFONT_H
- #include "FWFont.h"
- #endif
-
- // ----- Framewrk Includes -----
-
- #ifndef FWCONTRH_H
- #include "FWContrH.h"
- #endif
-
- #ifndef FWCONTRL_H
- #include "FWContrl.h"
- #endif
-
- #ifndef FWVIEWS_K
- #include "FWViews.k"
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- class FW_CViewContext;
-
- //========================================================================================
- // Button kinds
- //========================================================================================
-
- typedef unsigned long FW_ButtonKind;
-
- // Button kind constants are defined in <FWViews.k> in order to be used in resource files:
- // FW_kPushButton, FW_kRadioButton, FW_kCheckButton, FW_kDefaultPushButton
-
- //========================================================================================
- // CLASS FW_CButton
- //========================================================================================
-
- class FW_CButton : public FW_CNativeControl
- {
- // ----- Initialization/destruction
- public:
- FW_DECLARE_CLASS
- FW_DECLARE_AUTO(FW_CButton)
-
- // one-step initialization constructor
- FW_CButton(Environment* ev,
- FW_CSuperView* container,
- const FW_CRect& bounds,
- ODID viewID,
- FW_ButtonKind kind,
- const FW_CString& label,
- const FW_CFont& font = FW_kSystemFont,
- FW_Message msg = FW_kButtonPressedMsg,
- FW_ControlValue value = 0);
-
- // two-step initialization constructor
- FW_CButton(Environment* ev);
-
- virtual ~FW_CButton();
-
- // ----- Getters/Setters -----
- FW_ButtonKind GetButtonKind(Environment* ev) const;
- void SetButtonKind(Environment* ev, FW_ButtonKind kind);
-
- void SetState(Environment* ev, FW_Boolean on);
- FW_Boolean GetState(Environment* ev) const;
-
- // ----- Control API
- virtual void ControlClicked(Environment *ev, FW_ControlValue value, ODFacet* facet);
-
- // ----- View API
- virtual void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
-
- // ----- Archiving -----
- static void* Create(FW_CReadableStream& stream, FW_ClassTypeConstant type);
- static void Destroy(void* object, FW_ClassTypeConstant type);
- virtual void Flatten(Environment* ev, FW_CWritableStream& stream) const;
- virtual void InitializeFromStream(Environment* ev, FW_CReadableStream& stream);
-
- // ----- Utilities
- void SimulateButtonPressed(Environment* ev);
-
- protected:
- // ----- Internal use only
- virtual FW_Boolean PrivSetValue(Environment* ev, FW_ControlValue value, ODFacet* facet);
-
- private:
- void Initialize(Environment* ev,
- FW_ButtonKind kind,
- const FW_CString& label,
- const FW_CFont& font);
-
- #ifdef FW_BUILD_MAC
- short MacGetProcID();
- #endif
-
- // ----- Data
- private:
- FW_ButtonKind fKind;
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- inline FW_ButtonKind FW_CButton::GetButtonKind(Environment*) const
- {
- return fKind;
- }
-
- inline FW_Boolean FW_CButton::GetState(Environment* ev) const
- {
- return (GetValue(ev) == 0) ? false : true;
- }
-
- inline void FW_CButton::SetState(Environment* ev, FW_Boolean on)
- {
- SetValue(ev, on ? 1 : 0);
- }
-
- #endif
-